//
//  DBHelper.h
//  Moss
//
//  Created by administrator on 12-1-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DBVersionManager.h"
#import "FMDatabaseQueue.h"
#import "FMDatabase.h"
#import "FMResultSet.h"


@interface DBHelper : NSObject{
    NSMutableDictionary* mDBMap;
    NSMutableDictionary* mDBPathMap;
    dispatch_queue_t readqueue;
    dispatch_queue_t writequeue;
}

+(DBHelper*) getInstance;


// 初始化数据库版本
- (void)initDB:(NSString*)dbName
     dbVersion:(int)dbVersion
  AllDBVersion:(int)allDBVersion;

//获取一个初始化时已经创建好的数据库链接。
-(FMDatabaseQueue*)getDBQueue:(NSString*)dbName;
//新创建一个数据库链接并返回。如果不使用了，需要关闭并释放这个数据库链接。
-(FMDatabase*)getNewDB:(NSString*)dbName;
-(void)closeDBQueue:(NSString*)dbName;
-(void)runWrite:(void (^)(void))completion;
-(void)runRead:(void (^)(void))completion;
@end
